package com.jianzhile.jobs.base;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.view.MotionEvent;


public abstract class BaseActivity extends AppCompatActivity {
	public MyApplication mApplication;
	public Context context;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mApplication = (MyApplication) getApplication();
		mApplication.addActivity(this);
		context = this;
		initView(savedInstanceState);
		setListener();
		initData();
	}

	public abstract void initView(Bundle savedInstanceState);

	public abstract void setListener();

	public abstract void initData();




	@Override
	public boolean dispatchKeyEvent(KeyEvent event) {
		switch (event.getAction()) {
		case KeyEvent.ACTION_DOWN:
			// mHandler.removeMessages(MSG_SET_PATTERN);
			// mHandler.sendEmptyMessage(MSG_REMOVE_PATTERN);
			break;
		case KeyEvent.ACTION_UP:
			// mHandler.sendEmptyMessageDelayed(MSG_SET_PATTERN, DELAY_TIME);
			break;
		default:
			break;
		}

		return super.dispatchKeyEvent(event);
	}

	@Override
	public boolean dispatchTouchEvent(MotionEvent ev) {
		switch (ev.getAction()) {
		case MotionEvent.ACTION_DOWN:
			// mHandler.removeMessages(MSG_SET_PATTERN);
			// mHandler.sendEmptyMessage(MSG_REMOVE_PATTERN);
			break;
		case MotionEvent.ACTION_UP:
			// mHandler.sendEmptyMessageDelayed(MSG_SET_PATTERN, DELAY_TIME);
			break;
		default:
			break;
		}
		return super.dispatchTouchEvent(ev);
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		mApplication.activitys.remove(this);
	}

	@Override
	protected void onResume() {
		super.onResume();
		//在此集成友盟分析
		//MobclickAgent.onResume(this);
	}

	@Override
	protected void onPause() {
		super.onPause();
		//MobclickAgent.onPause(this);
	}
}
